package com.bbx.flink.demo.data_stream_state.keyed_state;

import com.bbx.flink.demo.data_stream_state.functions.ListStateDemo;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * keyedState   listState
 * 对输入元素  keyBy(....)   相同key 的元素放入一个list 中，然后输出
 * 例 依次输入   输入结果
 *     1         1
 *     3         1 ，3
 *     5         1，3，5
 *     2         2
 *     7         1，3，5，7
 *
 */
public class QueueElement {

    public static void main(String [] args) throws Exception {


        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.socketTextStream("192.168.10.131",10003)
                .map(i->Integer.parseInt(i))
                .keyBy(i->i%2==0)
                .flatMap(new ListStateDemo())
                .print();
        env.execute();


    }


}
